﻿CREATE TABLE [dbo].[Order] (
    [Id]                 INT              IDENTITY (1, 1) NOT FOR REPLICATION NOT NULL,
    [OId]                UNIQUEIDENTIFIER CONSTRAINT [DF_Order_OId] DEFAULT (newid()) NULL,
    [OrderId]            NVARCHAR (50)    NULL,
    [CusId]              UNIQUEIDENTIFIER NULL,
    [CusName]            NVARCHAR (200)   NULL,
    [CusName_BD]         NVARCHAR (100)   CONSTRAINT [DF_Order_CusName_BD] DEFAULT ('') NULL,
    [CusPerson]          NVARCHAR (50)    NULL,
    [CusPersonTel]       NVARCHAR (50)    NULL,
    [CusDescription]     NVARCHAR (MAX)   NULL,
    [CusEstimate]        NVARCHAR (200)   NULL,
    [TypeId]             INT              NULL,
    [TypeName]           NVARCHAR (50)    NULL,
    [WayId]              INT              NULL,
    [WayName]            NVARCHAR (50)    NULL,
    [ProcessId]          INT              NULL,
    [ProcessName]        NVARCHAR (50)    NULL,
    [Salesman]           NVARCHAR (50)    NULL,
    [SalesmanAccount]    NVARCHAR (50)    NULL,
    [TradeDate]          DATETIME         NULL,
    [CreateDate]         DATETIME         NULL,
    [YingShouPrice]      DECIMAL (18, 2)  CONSTRAINT [DF_Order_YingShouPrice] DEFAULT ((0)) NOT NULL,
    [ShiShouPrice]       DECIMAL (18, 2)  CONSTRAINT [DF_Order_ShiShouPrice] DEFAULT ((0)) NOT NULL,
    [Discount]           NVARCHAR (50)    NULL,
    [PaymentTypeId]      INT              NULL,
    [PaymentType]        NVARCHAR (50)    NULL,
    [BankId]             INT              NULL,
    [Bank]               NVARCHAR (50)    NULL,
    [PaymentDescription] NVARCHAR (200)   NULL,
    [OtherDescription]   NVARCHAR (1000)  NULL,
    [DepId]              INT              NULL,
    [CompanyId]          INT              NULL,
    [StateId]            INT              NULL,
    [FinanceRenlingDate] DATETIME         NULL,
    [IsGreen]            BIT              NULL,
    [TrackKfAccount]     NVARCHAR (50)    NULL,
    [TrackKfName]        NVARCHAR (50)    NULL,
    [TrackKfDepId]       INT              NULL,
    [GenJinKfAccount]    VARCHAR (30)     CONSTRAINT [DF_Order_TrackKfAccount1] DEFAULT ('') NULL,
    [GenJinKfName]       NVARCHAR (50)    CONSTRAINT [DF_Order_TrackKfName1] DEFAULT ('') NULL,
    [GenJinKfDepId]      INT              CONSTRAINT [DF_Order_TrackKfDepId1] DEFAULT ((0)) NULL,
    [flag]               INT              CONSTRAINT [DF_Order_flag] DEFAULT ((0)) NULL,
    [AuditPerson]        NVARCHAR (50)    CONSTRAINT [DF_Order_AuditPerson] DEFAULT ('') NULL,
    [AuditDate]          DATETIME         CONSTRAINT [DF_Order_AuditDate] DEFAULT ('1900-01-01') NULL,
    [shjbh]              NVARCHAR (50)    CONSTRAINT [DF_Order_shjbh] DEFAULT ('') NULL,
    [htbh]               NVARCHAR (50)    CONSTRAINT [DF_Order_htbh] DEFAULT ('') NULL,
    [NOE_Flag]           INT              CONSTRAINT [DF_Order_NOE_Flag] DEFAULT ((0)) NOT NULL,
    [ExCompanyId]        INT              CONSTRAINT [DF_Order_ExCompanyId] DEFAULT ((0)) NOT NULL,
    [FinishDate]         DATETIME         NULL,
    [F_YingShou]         DECIMAL (18, 2)  CONSTRAINT [DF_Order_F_YingShou] DEFAULT ((0)) NOT NULL,
    [TrackBDAccount]     VARCHAR (50)     CONSTRAINT [DF_Order_TrackBDAccount_1] DEFAULT ('') NULL,
    [TrackBDName]        NVARCHAR (50)    CONSTRAINT [DF_Order_TrackBDName_1] DEFAULT ('') NULL,
    [Analyse]            NVARCHAR (50)    NULL,
    [RCount]             INT              CONSTRAINT [DF_Order_RCount] DEFAULT ((0)) NULL,
    [H_YingShou]         DECIMAL (18, 2)  CONSTRAINT [DF_Order_H_YingShou] DEFAULT ((0)) NULL,
    [reserve1]           INT              CONSTRAINT [DF_Order_reserve1] DEFAULT ((0)) NULL,
    [reserve2]           INT              CONSTRAINT [DF_Order_reserve2] DEFAULT ((0)) NULL,
    [reserve3]           DECIMAL (18, 2)  CONSTRAINT [DF_Order_reserve3] DEFAULT ((0)) NULL,
    [reserve4]           DECIMAL (18, 2)  CONSTRAINT [DF_Order_reserve4] DEFAULT ((0)) NULL,
    [reserve5]           VARCHAR (50)     CONSTRAINT [DF_Order_reserve5] DEFAULT ('') NULL,
    [reserve6]           VARCHAR (50)     CONSTRAINT [DF_Order_reserve6] DEFAULT ('') NULL,
    CONSTRAINT [PK_Order] PRIMARY KEY CLUSTERED ([Id] ASC)
);


GO
CREATE NONCLUSTERED INDEX [IX_Order_OrderId]
    ON [dbo].[Order]([OrderId] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_CusId]
    ON [dbo].[Order]([CusId] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_SalesmanAccount]
    ON [dbo].[Order]([SalesmanAccount] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_TrackKfAccount]
    ON [dbo].[Order]([TrackKfAccount] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_CreateDate]
    ON [dbo].[Order]([CreateDate] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_FinishDate]
    ON [dbo].[Order]([FinishDate] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_AuditDate]
    ON [dbo].[Order]([AuditDate] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_Salesman]
    ON [dbo].[Order]([Salesman] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_TrackKfName]
    ON [dbo].[Order]([TrackKfName] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_TrackBDAccount]
    ON [dbo].[Order]([TrackBDAccount] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_TrackBDName]
    ON [dbo].[Order]([TrackBDName] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_GenJinKfAccount]
    ON [dbo].[Order]([GenJinKfAccount] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_GenJinKfName]
    ON [dbo].[Order]([GenJinKfName] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_CusName_BD]
    ON [dbo].[Order]([CusName_BD] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_NOE_FLAG]
    ON [dbo].[Order]([NOE_Flag] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_12c47312316f46c1b69a1a55b2e649f6]
    ON [dbo].[Order]([OId] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_dfd87390daac44649ebe5bbd3d66bf53]
    ON [dbo].[Order]([OId] ASC, [AuditDate] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_037684a3e01344048f4b25a70aaa3019]
    ON [dbo].[Order]([OId] ASC, [CompanyId] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_f5867ec1cf994a4d8981fc2cdd615e04]
    ON [dbo].[Order]([CompanyId] ASC, [CreateDate] ASC, [NOE_Flag] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_9c4aedbabcc34fe3b9f58e186c1da61c]
    ON [dbo].[Order]([OId] ASC, [StateId] ASC, [Analyse] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_7da7d570b7ac4db29fdd8e60b63d881f]
    ON [dbo].[Order]([OId] ASC, [TypeId] ASC, [StateId] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_a25465c892bc4745be2128053e909ac5]
    ON [dbo].[Order]([CompanyId] ASC, [NOE_Flag] ASC, [CreateDate] ASC, [StateId] ASC)
    INCLUDE([CusName]);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_a28c200205c24506855b5478f7390cb3]
    ON [dbo].[Order]([CompanyId] ASC, [StateId] ASC, [CreateDate] ASC, [NOE_Flag] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_1702dc35749047dda4367d8f613c4d46]
    ON [dbo].[Order]([StateId] ASC)
    INCLUDE([OrderId], [CusName], [TypeId], [WayId], [ProcessId], [Salesman], [YingShouPrice], [DepId], [CompanyId]);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_e11a4b4c6e134cbfb00fb93fb76d864c]
    ON [dbo].[Order]([FinanceRenlingDate] ASC)
    INCLUDE([CusName], [Salesman], [CompanyId], [StateId]);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_838624167cac4afbb7d1bdf825b2a6d4]
    ON [dbo].[Order]([SalesmanAccount] ASC, [NOE_Flag] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_250984e118824d6aa13d87cca60f63de]
    ON [dbo].[Order]([SalesmanAccount] ASC, [CompanyId] ASC, [NOE_Flag] ASC, [CreateDate] ASC)
    INCLUDE([CusName]);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_67835c59d59d446b85196de31c84f4ea]
    ON [dbo].[Order]([StateId] ASC, [CompanyId] ASC, [FinanceRenlingDate] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_03e484f8406e4ea89f225f85922fca65]
    ON [dbo].[Order]([TrackKfAccount] ASC, [CreateDate] ASC)
    INCLUDE([CusName]);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_0be24e603344480c85c94e635d815d46]
    ON [dbo].[Order]([TypeId] ASC, [CompanyId] ASC, [StateId] ASC, [CreateDate] ASC, [NOE_Flag] ASC);


GO
CREATE NONCLUSTERED INDEX [EFS_IX_Order_f5867ec1cf994a4d8981fc2cdd615e04_new]
    ON [dbo].[Order]([CompanyId] ASC, [CreateDate] ASC, [NOE_Flag] ASC);


GO
CREATE NONCLUSTERED INDEX [IX_Order_FinanceRenlingDate_StateId_NOEFlag]
    ON [dbo].[Order]([StateId] ASC, [FinanceRenlingDate] ASC, [NOE_Flag] ASC)
    INCLUDE([YingShouPrice], [ShiShouPrice], [CompanyId], [AuditDate]);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'财务认款日期', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'FinanceRenlingDate';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'绿色通道标志 1绿色通道 0常规', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'IsGreen';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'0：正常。1：表示该单已走绿色通道，但财务未认领款项。（财务认领后将值修改为0）', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'flag';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'审核人', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'AuditPerson';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'审核日期', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'AuditDate';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'收据编号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'shjbh';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'合同编号', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'htbh';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'非企成单标志 1非企 0常规2非常规', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'NOE_Flag';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'首次录入时的成单总额，财报统计专用', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'F_YingShou';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'发票数量', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'RCount';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'历史应收(成单时产生的)，统计用', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'H_YingShou';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'保留1', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'reserve1';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'保留2', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'reserve2';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'保留3', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'reserve3';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'保留4', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'reserve4';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'保留5', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'reserve5';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'保留6', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'Order', @level2type = N'COLUMN', @level2name = N'reserve6';

